﻿using System.Configuration;
namespace U01_boke
{
    /// <summary>
    /// AppSetting管理器
    /// </summary>
    public sealed class AppSettingsManage
    {
        /// <summary>
        /// 根据索引获取配置项
        /// </summary>
        /// <param name="index">索引</param>
        public static string GetValue(int index)
        {
            return ConfigurationManager.AppSettings[index];
        }
        /// <summary>
        /// 根据KeyName获取配置项
        /// </summary>
        /// <param name="index">KeyName</param>
        public static string GetValue(string name)
        {
            return ConfigurationManager.AppSettings[name];
        }
        /// <summary>
        /// 根据枚举索引获取配置项（注：枚举项顺序和AppSetting配置项顺序需保持一直）
        /// </summary>
        /// <param name="index">索引</param>
        public static string GetValue(AppSetting setting)
        {
            return ConfigurationManager.AppSettings[(int)setting];
        }
    }

    public enum AppSetting
    {
        /// <summary>
        /// 本地访问开关
        /// </summary>
        IsLocal,
        /// <summary>
        /// 缓存密钥
        /// </summary>
        CacheKey
    }
}